<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ include file="../head.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>babasport-list</title>

    <script type="text/javascript">
        function checkBox(name, checked) {
            $("input[name='" + name + "']").attr("checked", checked);
        }

        function optDelete() {
            var sizes = $("input[name='ids']:checked").size();
            if (sizes == 0) {
                alert("请至少选择一个品牌");
                return;
            }
            if (!confirm("确定删除吗？")) {
                return;
            }
            //提交删除
            $("#myids")[0].action = "delete.do";
            $("#myids").submit();
        }

      function de() {
            var ss=$("input[name='ids']").val();
          //提交删除
          $("#myids")[0].action = "delete.do?ids="+ss;
          $("#myids").submit();
        }

    </script>
</head>
<body>
<div class="box-positon">
    <div class="rpos">当前位置: 品牌管理 - 列表</div>
    <form class="ropt">
        <input class="add" type="button" value="添加" onclick="javascript:window.location.href='add.do'"/>
    </form>
    <div class="clear"></div>
</div>
<div class="body-box">
    <form action="list.do" method="get" style="padding-top:5px;">
        品牌名称: <input type="text" name="name" value="${name}"/>
        <%--方式1--%>
        <%--  <select name="isDisplay">
              <option value="1"  <c:if test="${isDisplay==1}">selected</c:if>>是</option>
              <option value="0"  <c:if test="${isDisplay==0}">selected</c:if>>否</option>
          </select>--%>

        <%--方式2--%>
        <select name="isDisplay">
            <option value="1">是</option>
            <option value="0">否</option>
        </select>
        <script type="text/javascript">

            $("select[name='isDisplay']").val('${isDisplay}');

        </script>

        <input type="submit" class="query" value="查询"/>
    </form>
    <form id="myids" method="post">
        <input type="hidden" name="name" value="${name}"/>
        <input type="hidden" name="isDisplay" value="${isDisplay}"/>
        <input type="hidden" name="pageNum" value="${page.pageNum}"/>

        <table cellspacing="1" cellpadding="0" border="0" width="100%" class="pn-ltable">
            <thead class="pn-lthead">
            <tr>
                <th width="20"><input type="checkbox" onclick="checkBox('ids',this.checked)"/></th>
                <th>品牌ID</th>
                <th>品牌名称</th>
                <th>品牌图片</th>
                <th>品牌描述</th>
                <th>排序</th>
                <th>是否可用</th>
                <th>操作选项</th>
            </tr>
            </thead>
            <tbody class="pn-ltbody">
            <c:forEach items="${page.result}" var="brand">
                <tr bgcolor="#ffffff" onmouseout="this.bgColor='#ffffff'" onmouseover="this.bgColor='#eeeeee'">
                    <td><input type="checkbox" value="${brand.id}" name="ids"/></td>
                    <td align="center">${brand.id}</td>
                    <td align="center">${brand.name}</td>
                    <td align="center"><img width="40" height="40" src="${brand.imgUrl}"/></td>
                    <td align="center">${brand.description}</td>
                    <td align="center">${brand.sort}</td>
                    <c:if test="${brand.isDisplay==1}">
                        <td align="center">是</td>
                    </c:if>
                    <c:if test="${brand.isDisplay==0}">
                        <td align="center">否</td>
                    </c:if>
                    <td align="center">
                        <a class="pn-opt" href="showEdit.do?brandId=${brand.id}">修改</a> | <a class="pn-opt"
                                                                                             onclick="if(confirm('您确定删除吗？')) {de()}"
                                                                                           href="#" >删除</a><%-- href="delete.do?ids=${brand.id}&name=${name}&isDisplay=${isDisplay}&pageNum=${page.pageNum}"--%>
                    </td>
                </tr>
            </c:forEach>


            </tbody>
        </table>
    </form>
    <div class="page pb15">
	<span class="r inb_a page_b">
	
		<font size="2"><a
                href="list.do?&amp;isShow=0&amp;pageNum=1&name=${name}&isDisplay=${isDisplay}">首页</a></font>

        <c:if test="${page.pageNum-1}>1"><font size="2"><a
                href="list.do?&amp;isShow=0&amp;pageNum=${page.pageNum-1}&name=${name}&isDisplay=${isDisplay}">上一页</a></font></c:if>


        <c:forEach begin="1" end="${page.pages}" var="pn">
            <c:if test="${page.pageNum==pn}"><strong>${pn}</strong></c:if>

            <c:if test="${page.pageNum!=pn}"><a
                    href="list.do?&amp;isShow=0&amp;pageNum=${pn}&name=${name}&isDisplay=${isDisplay}">${pn}</a></c:if>

        </c:forEach>

        <c:if test="${page.pageNum+1<page.pages}"><a
                href="list.do?&amp;isShow=0&amp;pageNum=${page.pageNum+1}&name=${name}&isDisplay=${isDisplay}"><font
                size="2">下一页</font></a></c:if>

		<a href="list.do?&amp;isShow=0&amp;pageNum=${page.pages}&name=${name}&isDisplay=${isDisplay}"><font
                size="2">尾页</font></a>
	
		共<var>${page.pages}</var>页 到第<input type="text" size="3" id="PAGENO"/>页 <input type="button"
                                                                                       onclick="javascript:window.location.href = 'list.do?&amp;isShow=0&amp;pageNum=' + $('#PAGENO').val() "
                                                                                       value="确定" class="hand btn60x20"
                                                                                       id="skip"/>
	
	</span>
    </div>
    <div style="margin-top:15px;"><input class="del-button" type="button" value="删除" onclick="optDelete();"/></div>
</div>
</body>
</html>